package com.ruoyi.hr.controller.hr.empInfo;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.empinfo.IncumbencyEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author zeo
 * @explain 在职员工、离职员工、退休员工、历史职员信息
 * @date 2020/4/2
 */
@Controller
@RequestMapping("empInfo/incumbencyEmp")
public class IncumbencyController extends BaseController {

    @Autowired
    IncumbencyEmpService incumbencyEmpService;

    @Autowired
    AuthorityService authorityService;

    private String prefix = "hr/empinfo/incumbencyemp";

    /**
     * 跳转分页页面
     */
    @GetMapping()
    public String incumbencyEmp() {
        return prefix + "/incumbencyEmp";
    }

    /**
     * 在职员工
     * @param map
     * @return
     */
    @RequestMapping("/findDataList")
    @ResponseBody
    public TableDataInfo findDataList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(incumbencyEmpService.findDataList(map, authority));
    }

    /**
     * 跳转离职员工分页页面
     */
    @GetMapping("quitEmp")
    public String quitEmp() {
        return prefix + "/quitEmp";
    }

    /**
     * 离职员工
     * @param map
     * @return
     */
    @RequestMapping("/findQuitList")
    @ResponseBody
    public TableDataInfo findQuitList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(incumbencyEmpService.findQuitList(map, authority));
    }

    /**
     * 跳转退休员工分页页面
     */
    @GetMapping("retireEmp")
    public String retireEmp() {
        return prefix + "/retireEmp";
    }

    /**
     * 退休员工
     * @param map
     * @return
     */
    @RequestMapping("/findRetireList")
    @ResponseBody
    public TableDataInfo findRetireList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(incumbencyEmpService.findRetireList(map, authority));
    }

    /**
     * 跳转历史职员信息分页页面
     */
    @GetMapping("empInfoHistory")
    public String empInfoHistory() {
        return prefix + "/empInfoHistory";
    }

    /**
     * 历史职员信息
     * @param map
     * @return
     */
    @RequestMapping("/empInfoHistoryList")
    @ResponseBody
    public TableDataInfo empInfoHistoryList(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        return getDataTable(incumbencyEmpService.empInfoHistoryList(map, authority));
    }
}
